import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  //我的组件路径##########################################begin
  /**
   * 数据分析##########################################
   */
  {
    path: '/sta',
    component: Layout,
    redirect: '/sta/create',
    name: '统计分析',
    meta: { title: '统计分析', icon: 'example' },
    children: [

      {
        path: 'show',
        name: '数据统计',
        component: () => import('@/views/pc/sta/index'),
        meta: { title: '数据统计', icon: 'tree' }
      }
    ]
  },

  {
    path: '/SpringAdmin',
    component: Layout,
    redirect: '/pc/SpringAdmin',
    name: '进程管理',
    meta: { title: '进程管理', icon: 'example' },
    children: [

      {
        path: 'boss',
        name: '进程管理',
        component: () => import('@/views/pc/admin/SpringAdmin'),
        meta: { title: '进程管理', icon: 'tree' }
      }
    ]
  },

  {
    path: '/Swagger',
    component: Layout,
    redirect: '/swagger/table', //路径
    name: '接口管理',
    meta: { title: '接口管理', icon: 'example' },
    children: [
      {
        path: 'PlaneApplication',  //子路径
        name: '航班管理', //小标题名
        component: () => import('@/views/pc/admin/PlaneApplication'),
        meta: { title: '航班管理', icon: 'table' }
      }, {
        path: 'UserApplication',  //子路径
        name: '用户管理', //小标题名
        component: () => import('@/views/pc/admin/UserApplication'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'UploadApplication',  //子路径
        name: '上传管理', //小标题名
        component: () => import('@/views/pc/admin/UploadApplication'),
        meta: { title: '上传管理', icon: 'table' }
      }, {
        path: 'TxSmsApplication',  //子路径
        name: '短信管理', //小标题名
        component: () => import('@/views/pc/admin/TxSmsApplication'),
        meta: { title: '短信管理', icon: 'table' }
      }, {
        path: 'OrderApplication',  //子路径
        name: '订单管理', //小标题名
        component: () => import('@/views/pc/admin/OrderApplication'),
        meta: { title: '订单管理', icon: 'table' }
      }
    ]
  },

  /**
   * 航班管理##########################################
   */
  {
    path: '/plane',
    component: Layout,
    redirect: '/plane/table', //路径
    name: '航班管理',
    meta: { title: '航班管理', icon: 'example' },
    children: [
      // {
      //   path: 'ticketing',  //子路径
      //   name: '票务列表', //小标题名
      //   component: () => import('@/views/pc/plane/myPlane/ticketing'),
      //   meta: { title: '票务列表', icon: 'table' }
      // },
      {
        path: 'table',  //子路径
        name: '航班列表', //小标题名
        component: () => import('@/views/pc/plane/index'),
        meta: { title: '航班列表', icon: 'table' },
        children: [
          {
            path: 'base',
            component: () => import('@/views/pc/plane/myPlane/base'),
            name: '普通航班',
            meta: { title: '普通航班' }
          },
          {
            path: 'transfer',
            component: () => import('@/views/pc/plane/myPlane/transfer'),
            name: '转程航班',
            meta: { title: '转程航班' }
          },
          {
            path: 'connecting',
            component: () => import('@/views/pc/plane/myPlane/connecting'),
            name: '联程航班',
            meta: { title: '联程航班' }
          }
        ]
      },

      {
        path: 'planeAction',
        name: '添加航班',
        component: () => import('@/views/pc/plane/index'),
        meta: { title: '添加航班', icon: 'table' },
        children: [
          //普通

          {
            path: 'baseSave',
            name: '添加普通航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/baseSave'),
            meta: { title: '添加普通航班', icon: 'tree' }
          },
          {
            path: 'editBase/:id',
            name: '编辑普通航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/baseSave'),
            meta: { title: '编辑航班', noCache: true },
            hidden: true
          },

          // 转程
          {
            path: 'transferSave',
            name: '添加转程航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/transferSave'),
            meta: { title: '添加转程航班', icon: 'tree' }
          },
          {
            path: 'editTransfer/:id',
            name: '编辑转程航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/transferSave'),
            meta: { title: '编辑转程航班', noCache: true },
            hidden: true
          },

          {
            path: 'connectingSave',
            name: '多程航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/ConnectingSave'),
            meta: { title: '添加联程航班', icon: 'tree' }
          },
          {
            path: 'editConnecting/:id',
            name: '编辑多程航班',
            component: () => import('@/views/pc/plane/mySaveOrUpdate/ConnectingSave'),
            meta: { title: '编辑联程航班', noCache: true },
            hidden: true
          }

        ]
      }

    ]
  },
  /**
   * 用户管理##########################################
   */
  {
    path: '/user',
    component: Layout,
    redirect: '/user/table', //路径
    name: '用户管理',
    meta: { title: '用户管理', icon: 'example' },
    children: [
      {
        path: 'table',  //子路径
        name: '用户列表', //小标题名
        component: () => import('@/views/pc/user/index'),
        meta: { title: '用户列表', icon: 'table' },
        children: [
          {
            path: 'user',
            name: '用户管理',
            component: () => import('@/views/pc/user/userList'),
            meta: { title: '用户管理' }
          },
          {
            path: 'admin',
            component: () => import('@/views/pc/user/adminList'),
            name: '管理员',
            meta: { title: '管理员' }
          }
        ]
      },

      {
        path: 'userAction',
        name: '添加用户',
        component: () => import('@/views/pc/user/index'),
        meta: { title: '添加用户', icon: 'table' },
        children: [
          {
            path: 'userSave',
            name: '添加用户',
            component: () => import('@/views/pc/user/userSave'),
            meta: { title: '添加用户', icon: 'tree' }
          },
          {
            path: 'userEdit/:id',
            name: '编辑用户',
            component: () => import('@/views/pc/user/userSave'),
            meta: { title: '编辑用户', noCache: true },
            hidden: true
          },
          {
            path: 'adminSave',
            name: '添加管理员',
            component: () => import('@/views/pc/user/adminSave'),
            meta: { title: '添加管理员', icon: 'tree' }
          },
          {
            path: 'adminEdit/:id',
            name: '编辑用户',
            component: () => import('@/views/pc/user/adminSave'),
            meta: { title: '编辑管理信息', noCache: true },
            hidden: true
          }
        ]
      }
    ]
  },

  /**
   * 订单管理##########################################
   */
  {
    path: '/order',
    component: Layout,
    redirect: '/order/table',
    name: '订单管理',
    meta: { title: '订单管理', icon: 'example' },
    children: [
      {
        path: 'table',
        name: '订单列表',
        component: () => import('@/views/pc/order/index'),
        meta: { title: '订单列表', icon: 'table' }
      },
      {
        path: 'tree',
        name: '日志列表',
        component: () => import('@/views/pc/order/orderlog'),
        meta: { title: '日志列表', icon: 'tree' }
      }
    ]
  },

  /**
   * other##########################################
   */




  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开    路由模块中定义路由
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
